package com.yiwei.hdb.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yiwei.hdb.R;
import com.yiwei.hdb.activity.HelpCenterActivity;
import com.yiwei.hdb.activity.HelpDetailActivity;
import com.yiwei.hdb.adapter.base.ItemAdapter;
import com.yiwei.hdb.constant.Const;
import com.yiwei.hdb.model.HelpModel;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by xsooy-pc on 2017/10/23.
 */

public class V4HelpItemAdapter extends ItemAdapter<HelpModel.HelpList, V4HelpItemAdapter.DefaultHolder> {


    private Context context;
    public V4HelpItemAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public DefaultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DefaultHolder(inflate(R.layout.item_help_item_v4, parent));
    }

    @Override
    public void onBindViewHolder(DefaultHolder holder, int position) {
        HelpModel.HelpList item = getItem(position);
        holder.txtTitle.setText(item.getTitle());
        holder.txtTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("id", item.getId());
                intent.putExtra("type", Const.FragmentType.HELP);
                intent.setClass(context, HelpDetailActivity.class);
                context.startActivity(intent);
            }
        });
    }

    class DefaultHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_title)
        TextView txtTitle;
        public DefaultHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
    public interface OnShareClickListener {
        void onClick(String bonus_id);
    }

    private OnShareClickListener shareClickListener;

    public void setShareClickListener(OnShareClickListener shareClickListener) {
        this.shareClickListener = shareClickListener;
    }
}
